package com.yx.robot.bean.robot;

/**
 * 地图数据
 * <p>
 * width 宽
 * height 高
 * resolution 分辨率
 * dockerPosX 充电座x
 * dockerPosY 充电座y
 * frameNumber当前地图帧数
 * mapId 地图id
 * pathId 路径ID
 * fullMapData 地图数据
 */
public class MapInfo implements Cloneable, Clear {

    public static final int TYPE_NONE = -2;   //墙外  未检测到的位置
    public static final int TYPE_ORIGIN = -1;     //检测到的原始数据  未分区
    public static final int TYPE_WALL = -3;        //墙
    public static final int TYPE_BORDER = -4;        //边界 由于显示比较完整的房间

    public static final int MAP_TYPE_GYRO = 1;        //陀螺仪扫地机
    public static final int MAP_TYPE_LASER = 2;        //激光扫地机

    public int mapType=MAP_TYPE_LASER;

    public int width;
    public int height;
    public float resolution; //与现实世界的比例(单位m/pixel)  例如 0.1  就代表地图一个点表示真实世界的0.1m
    public int frameNumber;
    public long mapId;
    public long pathId;
    public int[] mapData;


    public void clear() {
        mapData = null;
        pathId = -1;
        mapId = -1;
        frameNumber = -1;
        width = 0;
        height = 0;
        resolution = 1;
    }

    @Override
    public String toString() {
        return "Map{" +
                "width=" + width +
                ", height=" + height +
                ", resolution=" + resolution +
                ", frameNumber=" + frameNumber +
                ", mapId=" + mapId +
                ", pathId=" + pathId +
                '}';
    }


    @Override
    public Object clone() {
        try {
            return super.clone();
        } catch (CloneNotSupportedException e) {
            e.printStackTrace();
        }
        return new MapInfo();
    }

    public float getActualSize(float pixel) {
        return pixel * resolution;
    }

    public float getScreenSize(float size) {
        return size / resolution;
    }

}
